package vn.demand.dragon.model.business
{
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;
	
	public class CompleteProjectDelegate
	{
		private var service : HTTPService;
		private var responder : IResponder;
		
		public function CompleteProjectDelegate(result:Function, failed:Function)
		{
			service = new HTTPService();
			service.url = "http://dev.dragon.com/index.php?m=projects&a=do_project_complete_xml&suppressHeaders=1&"
			service.method = 'GET';
			service.resultFormat = 'e4x';
			
			service.addEventListener(ResultEvent.RESULT, result);
			service.addEventListener(FaultEvent.FAULT, failed);
		}
		
		public function complete(project_id, complete_date, on_step = 'VALIDATE'):void {
			var token : AsyncToken = service.send({'project_id': project_id, 'complete_date': complete_date, 'on_step': on_step});
			token.addResponder( responder );
			token.action = on_step;
		}

	}
}